const mongoose = require('mongoose')
const config = require('../config')
mongoose.Promise = global.Promise;
exports.mongoose = mongoose;
exports.connect = ()=>{
    mongoose.connect(config.MONGODG.uri,{config:{autoIndex:false}})
    mongoose.connection.on('error',errors=>{
        console.log('数据库连接失败',errors)
    })
    mongoose.connection.on('open',()=>{
        console.log('数据库连接成功')
    })
    return mongoose
}
